package com.dog.basics.netty.security;


import com.dog.basics.security.constants.SecurityConstants;
import com.dog.basics.security.provider.AuthenticationTokenParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
import org.springframework.stereotype.Component;

/**
 * MiniAppAuthenticationTokenParser
 *
 * @author dog
 * @date 2019-08-21
 */
@Component
public class MiniAppAuthenticationTokenParser implements AuthenticationTokenParser {
    @Autowired
    private RedisConnectionFactory redisConnectionFactory;

    @Override
    public AbstractAuthenticationToken parse(String authenticationTokenStr) {
        return null;
    }

    @Bean
    public TokenStore tokenStore() {
        RedisTokenStore tokenStore = new RedisTokenStore(redisConnectionFactory);
        tokenStore.setPrefix(SecurityConstants.Dog_PREFIX + SecurityConstants.OAUTH_PREFIX);
        return tokenStore;
    }
}
